﻿@using System.Dynamic;
@{  
    //Request.Validate=false;
    LayoutPage = "~/Administration/_SiteLayout.cshtml";
    PageData["Title"] = "Edit Meeting";
     
    dynamic meeting;
    var repository = new MeetingRepository();

    if(IsPost){
            dynamic postedMeeting = new ExpandoObject();
            postedMeeting.Date=Request["date"];
            postedMeeting.Topic=Request["topic"];
            postedMeeting.Abstract=Request["abstract"];
            postedMeeting.SpeakerName=Request["speakername"];
            postedMeeting.SpeakerUrl=Request["speakerurl"];
            postedMeeting.SpeakerBio=Request["speakerbio"];
            postedMeeting.Id=Request["id"];
        
            if(Request["id"]!=null && Request["id"]!=""){
                repository.Save(postedMeeting);
            }
            else{
                meeting = repository.Create(postedMeeting);
            }        
            Response.Redirect("listmeetings.cshtml");
        
        }

        if(Request["id"]!=null && Request["id"]!=""){
            meeting = repository.GetMeeting(Request["id"]);
        }
        else{
            meeting = repository.New();
        }
    }
    <SCRIPT type=text/javascript>
	$(function() {
		$("input[name$='date']").datepicker();
        $("textarea").wysiwyg();
	});
	</SCRIPT>

<form method="post">
    <FieldSet>
    <legend>Meeting</legend>
        <label for="date">Date:</label><input id="date" name="date" type="text" value="@meeting.Date"><br/>
        <label for="topic">Topic:</label><input name="topic" type="text" value="@meeting.Topic"><br/>
        <label for="abstract">Abstract</label><textarea id="abstract" name="abstract">@meeting.Abstract</textarea><br/>
        <label for="speakername">Speaker Name</label><input name="speakername" type="text" value="@meeting.SpeakerName"><br/>
        <label for="speakerurl">Speaker Url</label><input name="speakerurl" type="text" value="@meeting.SpeakerUrl"><br/>
        <label for="SpeakerBio">Speaker Bio</label><textarea name="speakerbio">@meeting.SpeakerBio</textarea><br/>
        <label> &nbsp;</label><input type="submit" value="Save">
    <Fieldset>
</form>